<input id="${name}_pic_upload_id" name="${name}" type="hidden" class="layui-input"/>
<button type="button" class="layui-btn layui-btn-sm" id="${name}_picbtn"><i class="layui-icon"></i>选择图片</button>
<div class="layui-upload-list">
    <img class="layui-upload-img" id="${name}_imgpreview" width="92px" height="92px">
</div>


<script>

    layui.use('upload',function () {
        var upload = layui.upload;
        var $ = layui.jquery;
        var uploadId = "#${name}_pic_upload_id";
        var btnId = "#${name}_picbtn";
        var tipsId = "#${name}_imgpreview";
        var hiddenInput = "#${name}_pic_upload_id";

        $(tipsId).on('updateImage',function () {
            var imgRes = $(hiddenInput).val();
            console.log(imgRes)
            $(this).attr('src', '${IMG}'+imgRes);
        });

        //普通图片上传
        upload.render({
            elem: btnId
            , url: Feng.ctxPath + '/system/uploadPath'
            , data:{'path':'${path}'}
            , before: function (obj) {
                obj.preview(function (index, file, result) {
                    $(tipsId).attr('src', result);
                });
            }
            , done: function (res) {
                $(uploadId).val(res.data.fileId);
                Feng.success(res.message);
            }
            , error: function () {
                Feng.error("上传图片失败！");
            }
        });
    })

</script>